﻿using Autofac;
using Autofac.Extras.DynamicProxy;
using Core.Infrastructures.Cores.Injections.Dependencies;
using System;
using System.Collections.Generic;
using System.Text;

namespace Core.Infrastructures.Cores.Injections.Modules
{
   public partial class RepositoryModule:Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterAssemblyTypes(Initialize.ReferencedAssemblies).PublicOnly()
                 .Where(type => !type.IsAbstract && typeof(IRepositoryDependency).IsAssignableFrom(type))
                 .AsImplementedInterfaces()
                 .EnableInterfaceInterceptors()
                // .InterceptedBy(
                //typeof(ProfilerInterceptor),
                //typeof(TransactionInterceptor))
                 .InstancePerLifetimeScope();    // 注册所有实现IRepositoryDependency接口的仓储对象，并基于请求创建
        }
    }
}
